<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #model{
            width:200px;
            height: 200px;
            border:1px solid gray;
        }
    </style>
</head>
<body>
    <button id="open">打开</button>
    <button id="close">关闭</button>

    <script>
        class Model{
            static getModel(){
                if(!Model.instance){
                    Model.instance = document.createElement('div');
                    Model.instance.innerHTML = '内容';
                    Model.instance.id = 'model';
                    Model.instance.style.display = 'none';
                    document.body.appendChild(Model.instance);
                }
                return Model.instance
            }
        }   
        
        let open = document.querySelector('#open');

        let close = document.querySelector('#close');

        open.addEventListener('click',() => {
            let model = Model.getModel();
            model.style.display = 'block';
        })

        close.addEventListener('click',() => {
            let model = Model.getModel();
            model.style.display = 'none';
        })
    </script>
</body>
</html>